import time
from datetime import timedelta

from utils.file_util import FileUtil
from sbs.wiz_convertor import WizConvertor


def main():
    print("转换 .json 文件为 wiz 文件")
    json_files = ["./data/PredefinedTypes.json",
                  "./data/PredefinedTypesC++.json", "./data/SysML.json"]
    wiz_files = ["./data/wiz/Uml.json", "./data/wiz/UmlC++.json", "./data/wiz/SysML.json"]

    for i in range(len(json_files)):
        convert(json_files[i], wiz_files[i])


def convert(json_file, wiz_file):
    convertor = WizConvertor(json_file)
    wiz = convertor.to_json()
    # 写入 .json 文件
    FileUtil.write_json_file(wiz_file, wiz)
    print(f"已将 {json_file} 转换为 {wiz_file}")


if __name__ == "__main__":
    start_time = time.time()
    main()
    end_time = time.time()
    print(timedelta(seconds=end_time - start_time))
